package cn.tedu.micro.demo.device.controller;

import cn.tedu.micro.demo.common.pojo.protocol.JsonResult;
import cn.tedu.micro.demo.common.pojo.vo.GunInfoVO;
import cn.tedu.micro.demo.device.service.GunService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GunController {
    @Autowired
    private GunService gunService;
    /**
     * 接收请求 完成枪查询功能
     */
    @GetMapping("/device/gun/info/{gunId}")
    public JsonResult<GunInfoVO> gunDetail(@PathVariable Long gunId){
        //控制层 要返回数据给前端使用,控制层返回什么 业务层就返回什么
        GunInfoVO gunInfoVO=gunService.gunDetail(gunId);
        return JsonResult.ok("ok",gunInfoVO);
    }

    @PostMapping("/device/test")
    public JsonResult<String> test(Integer id){
        return JsonResult.ok("ok",id+"");
    }
}
